import yaml
from peft import LoraConfig, TaskType

# 从 YAML 文件读取配置
def load_lo_conf(yaml_path):
    with open(yaml_path, "r") as f:
        config = yaml.safe_load(f)
    
    lo_conf = LoraConfig(
        r=config["r"],
        target_modules=config["target_modules"],
        task_type=TaskType[config["task_type"]],
        lora_alpha=config["lora_alpha"],
        lora_dropout=config["lora_dropout"]
    )
    return lo_conf

# 使用示例
lora_conf_pa = "finetune_config.yaml"
lo_conf = load_lo_conf(lora_conf_pa)
